package com.jixiantubu.adapter;

import java.util.List;

import com.example.jixiantubu.R;
import com.jixiantubu.bean.Photo_library;
import com.jixiantubu.bean.TupianBean;
import com.jixiantubu.tupianlunbo.ZoomImageView_fx;
import com.jixiantubu.util.MyApplication;
import com.lidroid.xutils.BitmapUtils;
import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout.LayoutParams;

public class MyPagerAdapter_youji extends PagerAdapter {
	List<Photo_library> list;
	Context context;
	BitmapUtils bitmapUtils;
    ViewPager viewPager;
    private List<ZoomImageView_fx> ziv_view;
	public MyPagerAdapter_youji(Context context, List<Photo_library> list) {
		MyApplication.bitmapUtils= new BitmapUtils(context);
		this.list=list;
	}

	@Override
	public int getCount() {
		return list.size();
	}
	@Override
	public Object instantiateItem(ViewGroup container, int position) {
		ZoomImageView_fx view = new ZoomImageView_fx(container.getContext());
		String url = "http://" + MyApplication.getIP()
				+ ":8080/Jinnang/img/"
				+ list.get(position).getpl_path();//网络图片路径
		MyApplication.bitmapUtils.configDefaultLoadFailedImage(R.drawable.error);
		MyApplication.bitmapUtils.configDefaultLoadingImage(R.drawable.loding);
		MyApplication.bitmapUtils.display(view, url);
		container.addView(view, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
		return view;
	}

	@Override
	public void destroyItem(ViewGroup container, int position, Object object) {
		container.removeView((View) object);
	}

	@Override
	public boolean isViewFromObject(View view, Object obj) {
		return view == obj;
	}
}
